from datetime import datetime

from django.db import models


class Users(models.Model):
    username = models.CharField(max_length=12, null=False)
    phone = models.CharField(max_length=11, null=False, unique=True)
    email = models.CharField(max_length=30, default="")
    photo = models.CharField(max_length=100, default="")
    nickname = models.CharField(max_length=15, null=True)
    country = models.CharField(max_length=200, null=True)
    city = models.CharField(max_length=100, null=True)
    region = models.CharField(max_length=200, null=True)
    address = models.CharField(max_length=200, null=True)
    password = models.CharField(max_length=20, null=False)
    age = models.IntegerField(default=18, null=True)
    gender = models.CharField(max_length=1, null=True)
    user_type = models.IntegerField(default=1, null=False)
    created = models.CharField(max_length=50, default=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
    updated = models.CharField(max_length=50, default=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))

    class Mate:
        db_table = "users"


class Boom(models.Model):
    url = models.CharField(max_length=200, null=False,
                           default="http://pic.wodingche.com/carimg/olckgkcov.jpeg")
    title = models.CharField(max_length=200, null=False, default="这是图片的描述")
    created = models.CharField(max_length=50, default=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
    updated = models.CharField(max_length=50, default=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
    status = models.IntegerField(default=1, null=False)


class NewsBody(models.Model):
    username = models.CharField(max_length=500, default="", null=False)
    user_id = models.IntegerField(default=0, null=False)
    title = models.CharField(max_length=200, default="")
    image_url = models.CharField(max_length=100, default="http://pic.wodingche.com/carimg/olckgkcov.jpeg")
    new_type = models.CharField(max_length=20, default="娱乐")
    content = models.TextField(max_length=10000, default="")
    url = models.CharField(max_length=100, default="https://new.qq.com/ch/ent/")
    created = models.CharField(max_length=50, default=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
    updated = models.CharField(max_length=50, default=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
    body = models.TextField(max_length=10000, default="")


class Comment(models.Model):
    username = models.CharField(max_length=200, default="")
    new_id = models.IntegerField(null=False)
    content = models.CharField(max_length=5000, default="")
    created = models.CharField(max_length=50, default=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
    updated = models.CharField(max_length=50, default=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
